package unionpay.web;

import unionpay.sdk.SDKUtil;

import javax.servlet.*;
import java.io.IOException;

public class CharsetEncodingFilter implements Filter {
	
	private String encodeString;
	
	
	public void destroy() {
	}

	public void doFilter(ServletRequest request, ServletResponse response,
                         FilterChain chain) throws IOException, ServletException {
		
		request.setCharacterEncoding(encodeString);
		response.setContentType("text/html; charset="+ SDKUtil.encoding_UTF8);
		chain.doFilter(request, response);
	}

	public void init(FilterConfig filterConfig) throws ServletException {
		encodeString=filterConfig.getInitParameter("encoding");
	}

}
